<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    
    <%@ page import="java.sql.*" %>
    <%@ page import="jdbc.ConnectionFactory" %>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>LOPS - Agendar Servico</title>
</head>
<body>
	<form action="servicoAgendado.jsp">
		<fieldset>
		<legend>Agendamento</legend>
		<%
		try {
	        Connection conexao = new ConnectionFactory().getConnection();
		 	PreparedStatement stmt = conexao.
	                 prepareStatement("select * from prestador where cd_prestador = " + request.getParameter("codprestador") + ";");
	         ResultSet rs = stmt.executeQuery();
	 
	         while (rs.next()){
	         %>
	         <table border=2>
	         	<tr>
	         		<td colspan=5><%out.print("<h3>" + rs.getString("ds_prestador_nome_fant") + "</h3>");%></td>
	         	</tr>
	         	<tr>
	         		<td><%out.print(rs.getString("end_prestador_rua"));%></td>
	         		<td><%out.print(rs.getString("end_prestador_num"));%></td>
	         		<td><%out.print(rs.getString("end_prestador_bairro"));%></td>
	         		<td><%out.print(rs.getString("end_prestador_cidade"));%></td>
	         		<td><%out.print(rs.getString("end_prestador_uf"));%></td>
	         	</tr>
	       <%
	      	}
	         rs.close();
	         stmt.close();
	     } catch (SQLException e) {
	         throw new RuntimeException(e);
	     }
			%>
	         	<tr>
	         		<td><label for="dia">Dia: </label></td>
	         		<td>
	         			<select name="dia">
	         				<option value="1">1</option>
	         				<option value="2">2</option>
	         				<option value="3">3</option>
	         				<option value="4">4</option>
	         				<option value="5">5</option>
	         				<option value="6">6</option>
	         				<option value="7">7</option>
	         				<option value="8">8</option>
	         				<option value="9">9</option>
	         				<option value="10">10</option>
	         				<option value="11">11</option>
	         				<option value="12">12</option>
	         				<option value="13">13</option>
	         				<option value="14">14</option>
	         				<option value="15">15</option>
	         				<option value="16">16</option>
	         				<option value="17">17</option>
	         				<option value="18">18</option>
	         				<option value="19">19</option>
	         				<option value="20">20</option>
	         				<option value="21">21</option>
	         				<option value="22">22</option>
	         				<option value="23">23</option>
	         				<option value="24">24</option>
	         				<option value="25">25</option>
	         				<option value="26">26</option>
	         				<option value="27">27</option>
	         				<option value="28">28</option>
	         				<option value="29">29</option>
	         				<option value="30">30</option>
	         				<option value="31">31</option>
	         			</select>
	         		</td>
	         	</tr>
	         	<tr>
	         		<td><label for="mes">Mes: </label></td>
	         		<td>
	         			<select name="mes">
	         				<option value="1">1</option>
	         				<option value="2">2</option>
	         				<option value="3">3</option>
	         				<option value="4">4</option>
	         				<option value="5">5</option>
	         				<option value="6">6</option>
	         				<option value="7">7</option>
	         				<option value="8">8</option>
	         				<option value="9">9</option>
	         				<option value="10">10</option>
	         				<option value="11">11</option>
	         				<option value="12">12</option>
	         			</select>
	         		</td>
	         	</tr>
	         	<tr>
	         		<td>
	        	        <label for="servico">Servico: </label>
	        	    </td>
	        	    <td>
	        	        <select name="servico">
	        	        <%
	         		try {
	        	        Connection conexao = new ConnectionFactory().getConnection();
	        		 	PreparedStatement stmt = conexao.
	        	                 prepareStatement("select * from servico where cd_prestador = " + request.getParameter("codprestador") + ";");
	        	         ResultSet rs = stmt.executeQuery();
	        	 
	        	         while (rs.next()){
	        	         %>
	        	         <option value="<%out.print(rs.getInt("cd_servico"));%>"><%out.print(rs.getString("ds_servico_nome"));%></option>
	        	    <%
	        	    	 }
	        	         rs.close();
	        	         stmt.close();
	        	     	 } catch (SQLException e) {
	        	         throw new RuntimeException(e);
	        	    	 }
	         		%>
	         	</tr>
	         	<tr>
	         		<td><input type="submit" value="Agendar"></td>
	         	</tr>
	         </table>
		</fieldset>
	</form>
</body>
</html>